#include "TargetState.h"
#include "Game.h"

TargetState::TargetState(void)
{
}


TargetState::~TargetState(void)
{
}

void TargetState::stateStarted() {
	Ogre::WindowEventUtilities::addWindowEventListener(Game::getInstance()->mWindow, this->windowEventListener);
	Game::getInstance()->mRoot->addFrameListener(this->frameListener);
	Game::getInstance()->mMouse->setEventCallback(this->MouseListener);
	Game::getInstance()->mKeyboard->setEventCallback(this->keyListener);
}

void TargetState::stateEnded() {

}

void TargetState::init()
{
	Game * game = Game::getInstance();

	Ogre::Entity* catapult = game->mSceneMgr->createEntity("catapult", "dangong.mesh");
	Ogre::SceneNode* catspultNode = game->mSceneMgr->getRootSceneNode()->createChildSceneNode();
	catspultNode->attachObject(catapult);
	catspultNode->translate(0.0f, 0.0f, 375.0f);
	//catspultNode->setScale(0.5f, 0.5f, 0.5f);

	TargetListener * lis = new TargetListener(game->mRoot,game->mCamera, 
		game->mSceneMgr,game->mWindow,game->mMouse,game->mKeyboard,game->mInputManager,catspultNode,game->mWorld);
	frameListener = lis;
	keyListener = lis;
	MouseListener = lis;
	windowEventListener=lis;
}
